home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / Gnuplot / Source / term / emxvga.trm < prev    next >
Encoding:
Text File  |  1993-03-02  |  3.3 KB  |  173 lines

  1. /* GNUPLOT - emxvga.trm */
  2. /*
  3.  * Copyright (C) 1993
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *
  15.  * This software  is provided "as is" without express or implied warranty.
  16.  *
  17.  * This file is included by ../term.c.
  18.  *
  19.  * This terminal driver supports:
  20.  *  vgal
  21.  *
  22.  * AUTHORS
  23.  *  Russell Lang
  24.  *
  25.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  26.  *
  27.  */
  28.  
  29. /* VGA driver using EMX/GCC for DOS */
  30. #include <graph.h>
  31. #include <conio.h>
  32. #include <dos.h>
  33.  
  34. int emx_startx, emx_starty;
  35. int emx_xlast, emx_ylast;
  36. int emx_color;
  37. int emx_angle;
  38. int emx_vmode = 0;
  39.  
  40. #define EMXVGA_XMAX 640
  41. #define EMXVGA_YMAX 480
  42.  
  43. #define EMXVGA_XLAST (EMXVGA_XMAX - 1)
  44. #define EMXVGA_YLAST (EMXVGA_YMAX - 1)
  45.  
  46. #define EMXVGA_VCHAR FNT5X9_VCHAR
  47. #define EMXVGA_HCHAR FNT5X9_HCHAR
  48. #define EMXVGA_VTIC 4
  49. #define EMXVGA_HTIC 4
  50.  
  51. #define EMXNUMCOLOR 15
  52. static int emx_colors[EMXNUMCOLOR] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  53.  
  54.  
  55. EMXVGA_init()
  56. {
  57. union REGS r;
  58.     r.h.ah = 0x0f;
  59.     _int86(0x10, &r, &r);
  60.     emx_vmode = r.h.al;    /* save old video mode */
  61.     /* Get the screen size: */
  62.     if (!g_mode(G_MODE_VGA_L))
  63.         int_error("Couldn't select graphics mode",NO_CARET);
  64.     emx_xlast = g_xsize - 1;
  65.         term_tbl[term].xmax = emx_xlast + 1;
  66.     emx_ylast = g_ysize - 1;
  67.         term_tbl[term].ymax = emx_ylast + 1;
  68.     g_mode(G_MODE_OFF);
  69. }
  70.  
  71. EMXVGA_graphics()
  72. {
  73. /* don't use g_mode() here - gmode(G_MODE_OFF) doesn't clean up */
  74. union REGS r;
  75.     r.h.ah = 0x00;
  76.     r.h.al = 19;        /* VGA 320x200x256 mode */
  77.     _int86(0x10, &r, &r);
  78. }
  79.  
  80. EMXVGA_text()
  81. {
  82. /* don't use g_mode() here - gmode(G_MODE_OFF) doesn't clean up */
  83. union REGS r;
  84.     (void)getch();
  85.     r.h.ah = 0x00;
  86.     r.h.al = emx_vmode;    /* old video mode */
  87.     _int86(0x10, &r, &r);
  88. }
  89.  
  90. EMXVGA_reset()
  91. {
  92. }
  93.  
  94. EMXVGA_linetype(linetype)
  95. int linetype;
  96. {
  97.     if (linetype >= 13)
  98.         linetype %= 13;
  99.     emx_color = emx_colors[linetype+2];
  100. }
  101.  
  102. EMXVGA_move(x,y)
  103. unsigned int x,y;
  104. {
  105.     emx_startx = x;
  106.     emx_starty = y;
  107. }
  108.  
  109.  
  110. EMXVGA_vector(x,y)
  111. unsigned int x,y;
  112. {
  113.     g_line(emx_startx,emx_ylast-emx_starty,x,emx_ylast-y,emx_color);
  114.     emx_startx = x;
  115.     emx_starty = y;
  116. }
  117.  
  118.  
  119. int EMXVGA_text_angle(ang)
  120. int ang;
  121. {
  122.     emx_angle=ang;
  123.     return TRUE;
  124. }
  125.  
  126.  
  127. EMXVGA_putc(x,y,c,angle)
  128. unsigned int x,y;
  129. char c;
  130. int angle;
  131. {
  132. int i,j,k;
  133. unsigned int pixelon;
  134.     i = (int)(c) - 32;
  135.     for (j=0; j<FNT5X9_VBITS; j++) {
  136.         for (k=0; k<FNT5X9_HBITS; k++) {
  137.             pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
  138.             if (pixelon) {
  139.                 switch(angle) {
  140.                     case 0 : g_set(x+k,y-j,emx_color);
  141.                             break;
  142.                     case 1 : g_set(x-j,y-k,emx_color);
  143.                             break;
  144.                 }
  145.             }
  146.         }
  147.     }
  148. }
  149.  
  150.  
  151. EMXVGA_put_text(x,y,str)
  152. unsigned int x, y;
  153. char *str;
  154. {
  155. int i;
  156.     switch(emx_angle) {
  157.         case 0 : y -= EMXVGA_VCHAR/2;
  158.                 break;
  159.         case 1 : x += EMXVGA_VCHAR/2;
  160.                 break;
  161.     }
  162.     for (i=0;str[i];i++) {
  163.         EMXVGA_putc(x,emx_ylast-y,str[i],emx_angle);
  164.         switch(emx_angle) {
  165.             case 0 : x+=EMXVGA_HCHAR ;
  166.                     break;
  167.             case 1 : y+=EMXVGA_HCHAR ;
  168.                     break;
  169.         }
  170.     }
  171. }
  172.  
  173.